<?php
	require "../dao/teacher_dao.php";
	
	session_start();
	$teacher = $_SESSION['teacher'];
 
	$stusecs = selectStusec();
	
	foreach($stusecs as $stusec){
		if($teacher["tattr"] == "ele"){
			if($stusec["sections"]){
				$val1 = null;
				$val1["sections"] = explode(",",$stusec["sections"]);
				$val2 = $stusec["stu_sec_spepul_id"];
				foreach($val1["sections"] as $val3){
					if($val3 == $teacher["tid"]){
						$students[] = selectStusecInfor($val2);
					}
				}
			}
		}else{
			if($stusec["spepul_sections"]){
				$val_1 = null;
				$val_1["spepul_sections"] = explode(",",$stusec["spepul_sections"]);
				$val_2 = $stusec["stu_sec_spepul_id"];
				foreach($val_1["spepul_sections"] as $val_3){
					if($val_3 == $teacher["tid"]){
						$students[] = selectStusecInfor($val_2);
					}
				}
			}
		}
	}
?>
<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<link rel="stylesheet" href="../css/register.css"/>
	<script src='../js/jquery-1.2.6.min.js'></script>
	<title>学生成绩输入界面</title>
	<style>
		.content{
			width:100%;
			height:480px;
			overflow: auto;
		}
		#tbl{
			width:800px;
			margin:0 auto;
			border-collapse: collapse;
		}
		#tbl th,#tbl td{
			border:1px solid #333;
			line-height: 35px;
		}
		#tbl tbody tr td{
			text-align: center;
		}
		input[type="text"]{
			width:100px;
		}
	</style>
</head>
<body>
	<div id="wrap">
		<form action="T_insertStu_mark_server.php" method="post" autocomplete="off">
			<input type="hidden" name="mark_tid"  value="<?=$teacher["tid"]?>"/>
			<div class="content">
				<table id="tbl">
					<thead>
						<tr>
							<th>编号</th>
							<th>姓名</th>
							<th>学号</th>
							<th>分数</th>
							<th>学院</th>
							<th>年级</th>
							<th>班级</th>
						</tr>
					</thead>
					<tbody>
						<?php
							if(count($students)){
								for($i=0;$i<count($students);$i++){
									$student = $students[$i];
						?>
								<tr>
									<td><?=$i+1?></td>
									<td><?=$student["sname"]?></td>
									<td><?=$student["snumber"]?></td>
									<td>
										<input type="text" name="mark[]" />
										<input type="hidden" name="mark_stuid[]"  value="<?=$student["stuid"]?>"/>
									</td>
									<td><?=$student["collegename"]?></td>
									<td><?=$student["gradename"]?></td>
									<td><?=$student["classname"]?></td>
								</tr>
						<?php
								}	
							}else{
						?>
								<script>
									alert("学校还没有为您安排教学班级或者还没有学生选这门课程。。。")
								</script>
						<?php
							}
							
						?>
					</tbody>
				</table>
			</div>
			<input type="reset" value="重   置" />
			<input type="submit" value="添   加"/>
		</form>
	</div>
</body>
</html>